//
//  FlightExplainController.m
//  ELife
//
//  Created by xiaozhi on 11-8-2.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "FlightExplainController.h"
#import "UIViewUtil.h"

@implementation FlightExplainController
@synthesize imgList = _imageList;

- (id)initWithImageList:(NSArray *)imgList
{
    self = [super initWithNibName:@"FlightExplainController" bundle:nil];
    if (self) {
        NSLog(@"retain count:%d", [imgList retainCount]);
        self.imgList = imgList;
        NSLog(@"retain count:%d", [imgList retainCount]);
    }
    
    return self;
}

- (void)dealloc
{
    [self.imgList release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.view.backgroundColor = [UIViewUtil getCommonBg];
    
    NSInteger y = 10;
    const NSInteger OFFSETY = 5;
    for (UIImage *img in self.imgList) {
        UIImageView *imageView = [[UIImageView alloc] initWithImage:img];
        
        NSInteger imgViewWid = imageView.frame.size.width;
        NSInteger imgViewHei = imageView.frame.size.height;
        NSInteger x = (self.view.frame.size.width - imgViewWid) / 2;
        
        
        imageView.frame = CGRectMake(x, y, imgViewWid, imgViewHei);
        [self.view addSubview:imageView];
        
        y += imgViewHei + OFFSETY;
        
    }
    
    self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, y);
    [((UIScrollView *)self.view) setContentSize:CGSizeMake(self.view.frame.size.width, self.view.frame.size.height)];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
